import ast.*;
import java_cup.runtime.*;

public class Test
{
	public static void main(String args[]) throws Exception
	{

		Yylex myScanner = new Yylex(System.in);
		parser myParser = new parser(myScanner);

		Symbol result = myParser.parse();

		RootNode root = (RootNode) result.value;

		if (root != null)
		{
			System.out.println("\nParsing completed\n\n");
			SimpleVisitor simpleVisitor = new SimpleVisitor();
			root.accept(simpleVisitor);
			System.out.println("\n\nSimpleVisitor Parsing Completed\n\n");
			BuildVisitor buildVisitor = new BuildVisitor();
			SymbolTable rootTable = (SymbolTable) root.accept(buildVisitor);
			System.out.println("\nSymbol table building complete\n\n");
			CheckVisitor checkVisitor = new CheckVisitor(rootTable);
			System.out.println("\nScope checking complete. Result: " + root.accept(checkVisitor).toString());
			TypeCheckVisitor tcv = new TypeCheckVisitor(rootTable);
			System.out.println("Type check status: "+ root.accept(tcv));
		} else
			System.out.println("Parsing failed");
	}

}
